#ifndef _TEXTURE_H_
#define _TEXTURE_H_

#include <windows.h>
#include <interfacelib/directx/InitD3D.h>

#define		MAX_MOTION_INDEX	64
#include <interfacelib/directx/imagelib.h>

#pragma warning ( disable : 4786 )
#include <list>
#include <map>

namespace interfacelib
{
	namespace DirectX
	{
		class Texture
		{

		private:	
			char m_fileName[ _MAX_PATH ];
			typedef std::map < WORD , MotionData * > mapMotion;	
			mapMotion *m_listMotion;

		public:
			Texture( const char *filename , mapMotion *motionData ) : m_listMotion( motionData )
			{
				strcpy( m_fileName, filename );

				m_maxWidth = 0;
				m_maxHeight = 0;
			};

			virtual ~Texture()
			{
				release();
				SAFE_DELETE( m_listMotion );
			};

			void release();

			void drawTexture( RECT *rect, D3DXVECTOR3 *vector, DWORD colorKey , SpriteData *currentSprite , D3DXVECTOR2 *scaling = NULL , int degree = 0 );
			void releaseTexture();
			char *getFileName(){ return ( m_fileName ); };


			void setMaxSize( DWORD width , DWORD heigth ){ m_maxWidth = width; m_maxHeight = heigth; };
			DWORD getMaxWidth()
			{
				return ( m_maxWidth );
			};
			DWORD getMaxHeight()
			{
				return ( m_maxHeight );
			};		

			LPDIRECT3DTEXTURE9 getSprite( BYTE motion, BYTE frame );
			void setCurrentMotionIndex( WORD index );
			MotionData *find( WORD index );
			MotionData *getFirstMotion();
			MotionData *getLastMotion();
			WORD getMaxMotionIndex(){ return ( ( WORD )m_listMotion->size() ); };

		private:
			DWORD m_maxWidth;
			DWORD m_maxHeight;
		};
	}
}

#endif
